package com.xm.servlet.background.commodity;

import com.xm.service.background.CommodityService;
import lombok.SneakyThrows;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;

/**
 * @author 康文程
 * @date 2024-1-17 下午 07:44
 */
@WebServlet("/background/update/commodity/price/by/id")
public class UpdateCommodityPriceByIdServlet extends HttpServlet {
    private final CommodityService service = new CommodityService();
    @SneakyThrows
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)  {
        Integer commodityId = Integer.parseInt(req.getParameter("commodityId"));
        BigDecimal newPrice = new BigDecimal(req.getParameter("newPrice"));
        resp.getWriter().print(service.updateCommodityPriceById(commodityId,newPrice));
    }
}
